/**
 * @author chuzhixin 1204505056@qq.com （不想保留author可删除）
 * @description 代码生成机状态管理
 */

const state = { routes: [] }

const getters = {
  getRoutePage: (state) => (route) => {
    var targe = state.routes.find((x) => x.path === route.path)
    if (targe) {
      return targe.params.pageData
    }
    return 1
  },
}

const mutations = {
  setRoutePage: (state, { route, pageData }) => {
    var targe = state.routes.find((x) => x.path === route.path)
    if (targe) {
      targe.params.pageData = pageData
      return
    }
    route.params.pageData = pageData
    state.routes.push(route)
  },
}
const actions = {
  setRoutePage ({ commit }, { route, pageData }) {
    commit('setRoutePage', { route, pageData })
  },
}
export default { state, getters, mutations, actions }
